/*=============================================================================
#    The element-comm is a tentative program used to test our ideas.           
#                       Copyright (C)  bgao                                    
#
#     This program is free software; you can redistribute it and/or            
#      modify it under the terms of the GNU General Public License             
#     as published by the Free Software Foundation; either version 2           
#         of the License, or (at your option) any later version.               
#
#     This program is distributed in the hope that it will be useful,          
#    but WITHOUT ANY WARRANTY; without even the implied warranty of           
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            
#             GNU General Public License for more details.                    
#
#    You should have received a copy of the GNU General Public License        
#     along with this program; if not, write to the Free Software             
#      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,             
#                       MA  02110-1301, USA.                                  
#==============================================================================
# $Id$ 
#
# $Author$ 
#
# $Revision$ 
#
# $Date$ 
#
# Description: 
#
=============================================================================*/
#include "rtos-wsn.h"


void wsn_context_init (struct context_info* context, void * stack,
					void (*entry)(void *), void * param)
{
	uint32 *p_stack = (uint32*)stack;
	
	/* save the entry and param  *//* stack = p_thread + p_attr->stacksize so start from -1 add by lfhan*/
	*(p_stack - 1) = (uint32)entry;
	*(p_stack - 2) = 0x0;/*R11*/
	*(p_stack - 3) = 0x0;/*R10*/
	*(p_stack - 4) = 0x0;/*R9*/
	*(p_stack - 5) = 0x0;/*R8*/
	*(p_stack - 6) = 0x0;/*R7*/
	*(p_stack - 7) = 0x0;/*R6*/
	*(p_stack - 8) = 0x0;/*R5*/
	*(p_stack - 9) = 0x0;/*R4*/

	p_stack = ((uint32*)stack - 9);

	/* save the stack pointer */
	context->sp = (uint32)p_stack;
	
}




